package com.project.system.service.impl;

import java.util.List;

import com.project.common.utils.TimeUuidUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.project.system.mapper.GoodsInfoMapper;
import com.project.system.domain.GoodsInfo;
import com.project.system.service.IGoodsInfoService;
import com.project.common.utils.str.Convert;

/**
 * 餐饮 服务层实现
 *
 * @author administrator
 * @date 2021-02-16
 */
@Service
public class GoodsInfoServiceImpl implements IGoodsInfoService {
    @Autowired
    private GoodsInfoMapper goodsInfoMapper;

    /**
     * 查询餐饮信息
     *
     * @param goodsId 餐饮ID
     * @return 餐饮信息
     */
    @Override
    public GoodsInfo selectGoodsInfoById(Long goodsId) {
        return goodsInfoMapper.selectGoodsInfoById(goodsId);
    }

    /**
     * 查询餐饮列表
     *
     * @param goodsInfo 餐饮信息
     * @return 餐饮集合
     */
    @Override
    public List<GoodsInfo> selectGoodsInfoList(GoodsInfo goodsInfo) {
        return goodsInfoMapper.selectGoodsInfoList(goodsInfo);
    }

    /**
     * 新增餐饮
     *
     * @param goodsInfo 餐饮信息
     * @return 结果
     */
    @Override
    public int insertGoodsInfo(GoodsInfo goodsInfo) {
        goodsInfo.setGoodsId(TimeUuidUtil.get16UUID());
        return goodsInfoMapper.insertGoodsInfo(goodsInfo);
    }

    /**
     * 修改餐饮
     *
     * @param goodsInfo 餐饮信息
     * @return 结果
     */
    @Override
    public int updateGoodsInfo(GoodsInfo goodsInfo) {
        return goodsInfoMapper.updateGoodsInfo(goodsInfo);
    }

    /**
     * 删除餐饮对象
     *
     * @param ids 需要删除的数据ID
     * @return 结果
     */
    @Override
    public int deleteGoodsInfoByIds(String ids) {
        return goodsInfoMapper.deleteGoodsInfoByIds(Convert.toStrArray(ids));
    }

    @Override
    public int updateGoodsLeft(GoodsInfo goodsInfo) {
        return goodsInfoMapper.updateGoodsLeft(goodsInfo);
    }

    @Override
    public Double queryGoodsLeft(Long goodsId) {
        return goodsInfoMapper.queryGoodsLeft(goodsId);
    }

}
